﻿@using Vote.Models;
@{
    ViewBag.Title = "FestivalDetail";
    FestivalModel Model = ViewBag.Model;
    Layout = null;
    var titleName = Model.VoteShowMo.Identify+"号的" + Model.VoteShowMo.Name + ",正在参加2017柳州“童心 同乐”六一少儿艺术展演";
    var DescriptTemp = Model.VoteShowMo.Describle;
    int page = ViewBag.page;
    double scrollNum = ViewBag.scrollNum;
    long voteShowId=ViewBag.voteShowId;
    bool isSubscribe = ViewBag.isSubscribe;
}
<link href="@Url.Content("~/Content/common.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/jquery-weui.css")" rel="stylesheet" type="text/css" />
<!DOCTYPE html>
<html>
<head>
    <title>@titleName</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <style>
        body { background: #795dc3;    padding-bottom: 15rem;  }
        .tou{ padding: 0;pointer-events:none;  background-color: #f7f7f7;  color:#afafaf;   display: block;width: 4rem;text-align: center;border-radius: 3px;height: 1.8rem;line-height: 1.8rem;font-size: 90%; margin-top: 1.5rem;font-weight: 600;}

    </style>
    <script>
    var _hmt = _hmt || [];
    (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?4fd648fda0a3af92d7a11dfd25b34442";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
    </script>
</head>

<body>
    <input type="hidden" id="page" value="@page" />
    <input type="hidden" id="scrollNum" value="@scrollNum" />
    <input type="hidden" id="voteShowId" value="@voteShowId" />
    <input type="hidden" value="@isSubscribe" id="isSubscribe" />
    <!--分享朋友圈-->
    <div id='wx_pic' style='margin:0 auto;display:none;'>
        <img src="@Url.Content("~/images/123.jpg")" />
    </div> 
    <!--头部开始-->
    @*<div class="header">
        <div class="header-bottom-left fl">
            <a href="javascript:history.back(-1);"><img class="bottom-icon" src="@Url.Content("~/images/left-bottom.png")"><span class=" return-text">返回</span></a>
        </div>
        <div class="header-title fl">
            <h3>节目详情</h3>
        </div>
        <div class="header-title-right fr">
            <a href="#"><h3 style="font-size: 1.8rem;color: #fff;margin-top: -0.5rem;">...</h3></a>
        </div>
    </div>*@
    <!--一分钱抢大米-->
  
    <a class="header-dami" href="http://m.gxanr.com/Product/16800.html">
        <img src="@Url.Content("~/images/shopping.gif")" />
    </a>
   

    <!--分享弹框-->
    <div class="share-bg" style="width: 100%;height: 100%;position: fixed;top: 0;left: 0;z-index: 99999;background-color: rgba(51, 51, 51, .7);display: none;">
        <div class="share-box" style="padding: 0.7rem;">
            <img style="width: 100%;" src="@Url.Content("~/images/share.png")">
        </div>
    </div>

    <!--主图-->
    <div class="home-iocn">
        <img src=@Model.VoteShowMo.ImgUrl.Replace("_source","_m")>
    </div>
    <!--投票-->
    <div class="vote-box">
        <div class="vote-text vote-left fl">
            <h4>节目名称: <span>@Model.VoteShowMo.Name</span></h4>
            <h4>编号：<span>@Model.VoteShowMo.Identify</span></h4>
            <h4>机构名称: <span>@Model.VoteShowMo.Company</span></h4>
            <h4>票数：<span id="VoteNum_temp">@Model.VoteShowMo.VoteNum</span></h4>
        </div>
        <div class="vote-text fl">
            @if (Model.canVoteType == 1)
            {
                <a class="tou-a" onclick="toupiao(this)" id=@Model.VoteShowMo.Id>投票</a>
            }
            else if (Model.canVoteType == 0)
            {
                <a class="tou" style="  background-color: #f7f7f7;  color:#afafaf;cursor:default" id=@Model.VoteShowMo.Id>已投</a>
            }
            else if (Model.canVoteType == 2)
            {
                <a class="tou" style="   background-color: #f7f7f7;   color:#afafaf;cursor:default" id=@Model.VoteShowMo.Id>投票</a>
            }
            else
            {
                <a class="tou" style="   background: #a8e9ff;    color: #795dc3;cursor:default" id=@Model.VoteShowMo.Id>投票</a>
            }
            <a class="fen-a" onclick="Share()">分享</a>
        </div>
    </div>
    <!--视频-->
    <div class="video-box">
        <ul class="video-list">
            @if (Model.VoteVi.Count > 0)
            {
                foreach (var video in Model.VoteVi)
                {
                    <li>
                        @*<a href=@video.VideoUrl><img src=@video.VideoImageUrl></a>*@
                        <div class="video-img-box">
                            <img class="video-img" src=@video.VideoImageUrl.Replace("_source","_ss")>
                        </div>
                        <div class="vote-btn">
                            <a href=@video.VideoUrl><img class="vote-btn-img" src="@Url.Content("~/images/video-btn_03.png")"></a>
                        </div>
                    </li>                                           
                
                }
            }
        </ul>
    </div>
    <div>
    </div>
    <!--节目详情， ，    -->
    @*<div class="tu-text">@Html.Raw(Model.VoteShowMo.Describle)
    </div>*@
   
    <div class="tu-text">
        <div class="explain">
            @Html.Raw(DescriptTemp)      
            @*<div class="explain-icon">
                <img src=@Model.VoteShowMo.ImgUrl.Replace("_source","_m")>
            </div>*@
        </div>
     </div>
    <!--footer菜单-->
    <ul class="footer-menu">
        <li><a href="/Home/Votes">参赛节目</a></li>
        <li><a href="/Home/Regulation">赛事规则</a></li>
        <li><a href="http://m.gxanr.com">爱农人商城</a></li>
    </ul>
    <!--关注二维码弹框-->
    <div class="ewm">
        <div class="ewm-bg">
            <div class="ewm-box">
                <h3>第一步：长按二维码并关注</h3>
                <div class="ewm-img">
                    <img src="~/Content/img/gxanrQrCode.jpg">
                </div>
                <h3>第二步：进入公众号投票</h3>

                <div class="close">
                    取消
                </div>
            </div>
        </div>
    </div>
    <script src="@Url.Content("~/Scripts/jquery-1.9.1.min.js")"></script>
    <script src="@Url.Content("~/Scripts/fastclick.js")"></script>

    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script>
        // jssdk config 对象
        var jssdkconfig;
        $(function () {
            $.ajax({
                type: "get",
                url: "http://m.gxanr.com/anrweixin/voteshare.php?do=jssdk&ajax=1&acid=2&ajaxurl=" + encodeURIComponent(location.href),
                dataType: "jsonp",
                success: function (ret) {
                    if (ret.appId) {
                        jssdkconfig = ret;
                        // 是否启用调试
                        jssdkconfig.debug = false;
                        jssdkconfig.jsApiList = [
                            'checkJsApi',
                            'onMenuShareTimeline',
                            'onMenuShareAppMessage',
                            'onMenuShareQQ',
                            'onMenuShareWeibo',

                        ];
                        wx.config(jssdkconfig);
                    }
                }
            });

            var isSubscribe = $("#isSubscribe").val();
            if (!isSubscribe) {
                $(".ewm").show();//未关注公众号
            }
        });


        var voteShowId=$("#voteShowId").val();

        //alert(JSON.stringify(jssdkconfig))
        var sharedata = { "desc": "投票即可获得0.1元购买五常大米一斤，先到先得，快来点我吧", "title": "爱农人2017柳州“童心 同乐”六一少儿艺术展演", "imgUrl": "http://vote.gxanr.com/content/img/share.png", "link": "http://vote.gxanr.com/home/FestivalDetail?VoteShowId=" + voteShowId };

        wx.ready(function () {
            wx.onMenuShareAppMessage(sharedata);
            wx.onMenuShareTimeline(sharedata);
            wx.onMenuShareQQ(sharedata);
            wx.onMenuShareWeibo(sharedata);
        });
    </script>



    <script>
        function ListnerFestival() {
            pushHistory();
            window.addEventListener("popstate", function (e) {
                //alert("我监听到了浏览器的返回按钮事件啦");//根据自己的需求实现自己的功能 
                var page = $("#page").val();
                var scrollNum = $("#scrollNum").val();
                window.location = '/Home/Votes?page=' + page + '&scrollNum=' + scrollNum;
            }, false);
            function pushHistory() {
                var state = {
                    title: "title",
                    url: "#"
                };
                window.history.pushState(state, "title", "#");
            }
        }

        $(function() {
            FastClick.attach(document.body);
            ListnerFestival()
            //sessionStorage.setItem("need-refresh", true);
            ////从爱农人返回，刷新页面
            //var Status = sessionStorage.getItem("Status");
            //if (Status == 1) {
            //    sessionStorage.removeItem("Status");
            //    location.reload();
            //}
            //电脑客户端打开弹出二维码
            var isPc = /macintosh|window/.test(navigator.userAgent.toLowerCase());
            if (isPc) {
                window.location.href = "/Home/ComputerCode";
            }
        });
        function confirmHtml(text, LeaveVoteNum, flage) {
            var htmlDemp = '';
            var htmlBody = '';
            //单选、多选样式判断
            if (!flage) {
                htmlDemp = ' <div class="ding-hui  fl" style="margin-left:0.5rem;background:#795dc3;color:#fff;" onclick="CancelConfirm(this)">'
                            + ' 取消'
                            + '</div>';
                htmlBody = '<div class="footer-tan">'
                            + ' <div class=" ding-hui fl" style="color:#795dc3;"onclick="SkipConfirm(this)" LeaveVoteNum=' + LeaveVoteNum + '>'
                            + ' 确定'
                            + '</div>' + htmlDemp
                           + '</div>';
            }
            else {
                htmlBody = '<div class="footer-tan">'
                            + ' <div class=" ding-hui fl" style="color:#fff;margin-left:27%;background:#795dc3;"onclick="SkipConfirm(this)" LeaveVoteNum=' + LeaveVoteNum + '>'
                            + ' 确定'
                            + '</div>' + htmlDemp
                           + '</div>';
            }
            var html = '<div class="tan">'
                  + '<div class="tan-bg">'
                      + '<div class="tan-box">'
                         + '<h3>'
                            + '<a  onclick="CancelConfirm(this)" LeaveVoteNum=' + LeaveVoteNum + '>'
                                + text
                            + '</a>'
                         + '</h3>' + htmlBody
                      + '</div>'
                  + ' </div>'
                 + ' </div> ';
            $('body').append(html);
            $(".tan").show();
        }
        //弹框,确认跳转到微商城
        function SkipConfirm(obj) {
            $(".tan").hide();
            var LeaveVoteNum = $(obj).attr("LeaveVoteNum");
            if (LeaveVoteNum == 0) {
                //用于微信返回操作
                //sessionStorage.setItem("Status","1");
                window.location.href = "http://m.gxanr.com/?status=2&VoteShowId=" + '@Model.VoteShowMo.Id';
            }
        }
        //取消
        function CancelConfirm(obj) {
            $(".tan").hide();
        }
        var showIds = 0;
        function toupiao(obj) {
            $(".tou-a").click(function () {
                $(".weui-mask,.weui-dialog").hide();
            })

            showIds = $(obj).attr("id");
            //var ancestors = $(obj).parent().parent().parent();
            $.ajax({
                type: "post",
                url: '@Url.Action("VoteByUser","Home")',
                data: { showId: showIds },
                async: false,
                success: function (result) {
                    if (isNaN(result.returnUrl)) {
                        if (result.returnUrl == "code") {
                           $(".ewm").show();//未关注公众号
                        }
                        else {
                            window.location.href = result.returnUrl; //重定向
                        }
                    } else {
                        if (result.VoteNum == 0) {
                            confirmHtml("今天已经投过了这个节目", 1, true);
                        }
                        else if (result.VoteNum == -2) {

                            //投票已经用完
                            confirmHtml("这个场次的投票已经用完,", 1, true);
                        }
                        else {
                            //ListnerFestival();
                            $(obj).html("已投");
                            $(obj).removeAttr("onclick");
                            $(obj).addClass("weui-btn weui-btn_disabled weui-btn_default");
                            $("#VoteNum_temp").text(result.VoteNum);
                            if (result.result != null) {
                                var Message = "第一次投票，赠送了爱农人优惠券";
                                confirmHtml(Message, 1, true);
                            }
                            if (result.LeaveVoteNum == 0) {
                                //sessionStorage.setItem("VoteNumSession", result.VoteNum);
                                //sessionStorage.setItem("VoteNumSessionIds", showIds);
                                var txt = "今天的投票已经用完，您可以前往爱农人商城使用您的优惠券";
                                confirmHtml(txt, 0, false);
                                return;
                            }
                            //sessionStorage.setItem("VoteNumSession", result.VoteNum);
                            //sessionStorage.setItem("VoteNumSessionIds", showIds);
                            //sessionStorage.setItem("LeaveVoteNum", result.LeaveVoteNum);
                        }
                    }
                }
            });
        }
    </script>
    <script src="@Url.Content("~/Scripts/jquery-weui.min.js")"></script>
    <script src="@Url.Content("~/Scripts/swiper.min.js")"></script>

    <script>
    $(".swiper-container").swiper({
        loop: true,
        autoplay: 3000
    });
  //  $(".fen-a").click(function () {
   //     $(".share-bg").show();
   // });
    function Share() {
        $(".share-bg").show();
    }
    $(".share-bg").click(function () {
        $(this).hide();
    })
    $(".close").click(function () {
        $(".ewm").hide();
        $("#" + showIds).removeClass("tou");
    });
    $(".tou-a").click(function () {
        $(this).addClass("tou");
    });
    </script>
</body>
</html>
